import 'package:flutter/material.dart';
import 'package:flutter_shensu/common/style/AiSuColors.dart';
import 'package:flutter_shensu/page/allgame_page.dart';
import 'package:flutter_shensu/page/overseas_page.dart';

class AllGameViewPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _AllGameViewPageState();
}

class _AllGameViewPageState extends State<AllGameViewPage>
    with
        SingleTickerProviderStateMixin,
        AutomaticKeepAliveClientMixin<AllGameViewPage> {
  TabController _tabController;

  List<Widget> _tabBarTitle = [
    Tab(text: '全部游戏'),
    Tab(text: '海外游戏'),
  ];

  List<Widget> _tabBarPage = [
    AllGamePage(),
    OverseasGamePage(),
  ];

  @override
  void initState() {
    super.initState();
    _tabController = new TabController(length: 2, vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _tabController.dispose();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(AiSuColors.primaryAiSuValue),
        title: TabBar(
          indicatorSize: TabBarIndicatorSize.label,
          indicatorColor: Colors.white,
          tabs: _tabBarTitle,
          controller: _tabController,
        ),
      ),
      body: TabBarView(
        controller: _tabController,
        children: _tabBarPage,
      ),
    );
  }

  @override
  // TODO: implement wantKeepAlive
  bool get wantKeepAlive => true;
}
